Pruning Contracts with Rosette
نویسنده
چکیده
Contracts are a pragmatic tool for managing software systems, but programs using contracts suffer runtime overhead. If this overhead becomes a performance bottleneck, programmers must manually edit or remove their contracts. This is no good. Rather, the contracts should identify their own inefficiencies and remove unnecessary dynamic checks. Implementing contracts with Rosette is a promising way to build such self-aware contracts. 1. The Trouble with Contracts Racket’s higher-order contracts [3] are an expressive and easy-touse specification language. Any programmer can design a contract, as the language for building contracts is essentially Racket. For example, the following program defines a function even++ that accepts only even numbers and returns only odd numbers. The contract combinator -> specifies the behavior of even++ using the predicates even? and odd?. #lang racket/base (require racket/contract) (define (even? x) (zero? (modulo x 2))) (define (odd? x) (even? (+ x 1))) (define/contract (even++ n) (-> even? odd?) (+ n 1)) Beyond Racket’s particular implementation, this idea of Design by Contract [4] scales to large programs [1] and complex specifications [2]. The trouble with a guarded function such as even++ is that each one call to the function triggers three function calls. An application (even++ 4) must first assert that 4 is an even number, then apply even++, and finally assert that 5 is an odd number. Checking the precondition even? is a necessary overhead, but clearly the postcondition odd? will never fail. In other words, (even? v) implies (odd? (even++ v)) for any possible input v. Contracts on higher-order functions may lead to even worse overhead. To illustrate the potential issue, consider an identity function specified over functions similar to even++: (define/contract (identity f) (-> (-> even? odd?) (-> even? odd?)) f) The application (identity even++) consequently applies the contract (-> even? odd?) twice more to even++. Calling ((identity even++) 4) asserts that 4 is an even number three times. In more realistic programs, similar higher-order contracts have led to order-of-magnitude [10] and exponential [9] performance overhead.
منابع مشابه
The Effect of chick Embryonic Somites on Neural Rosette Formation in Mouse Embryonic Stem Cells
purpose: The aim of the present study is to understand if EBs can generate neural rosette upon co-culture with chick embryo somites. Materials and Methods: The mouse ES cells, line Royan Bl, were cultured in hanging drops to induce embryoid bodies (EBs) formation. Somites were isolated from the chick embryos and then embedded in alginate solution. Finally, alginate beads containing somites were...
متن کاملInvestigating Effect of Short, Medium, and Long Pruning on Yield And Yield Components of Tayefi Grape Before and After Winter Cold
One of the most important operations in managed gardens is pruned grapes. For evaluate the effect of pruning short, medium, heavy on yield and yield components of Taif grapes, before and after the cold winter, in the years 2012 to 2013, A factorial experiment in a CRBD design with five replicates were performed on two factors. The first factor was the number of buds per stem and included the th...
متن کاملThe Effects of Pruning and Potassium Nutrition on Some Morphological Traits and Seedling Properties of Pumpkin (Cucurbita pepo L.)
In order to investigate the effect of pruning and potassium nutrition on pumpkin grain yield and quality, a factorial experiment based on complete block design with four replications was carried out in nooshar village of ardabil province, Ardabil, Iran, in 2007. Experimental factors include potassium nutrition in three level (0, 75 and 150 kg/ha from potassium sulfate) and stem pruning (without...
متن کاملInvestigating Effect of Short, Medium, and Long Pruning on Yield And Yield Components of Tayefi Grape Before and After Winter Cold
One of the most important operations in managed gardens is pruned grapes. For evaluate the effect of pruning short, medium, heavy on yield and yield components of Taif grapes, before and after the cold winter, in the years 2012 to 2013, A factorial experiment in a CRBD design with five replicates were performed on two factors. The first factor was the number of buds per stem and included the th...
متن کاملEffect of pruning on growth, development, seed yield and active substances of Pumpkin (Cucurbita pepo convar. pepo var. styriaca)
The objective of this study was to investigate the effect of pruning in different developmental stages on growth, development, seed yield and active substances of medicinal pumpkin (these active substances are uses for remedy the Benign Prostatic Hyperplasia (BPH)). The experiment was performed in a RCB design. Five pruning treatments in different developmental stages (no pruning, after 3-5 nod...
متن کامل